//
//  KefuViewController.m
//  specialine
//
//  Created by 往返网络 on 17/3/16.
//  Copyright © 2017年 com. All rights reserved.
//

#import "KefuViewController.h"  //客服中心

@interface KefuViewController ()

@end

@implementation KefuViewController
{

    NSString * phonestring; //拨打电话号

    UILabel * phonelab; //客服电话
    
    UIButton * phonebtn; //按钮
}

- (void)viewWillAppear:(BOOL)animated{
    
    self.navigationController.navigationBar.hidden = YES;
    
    self.tabBarController.tabBar.hidden = YES;
    
}


- (void)viewWillDisappear:(BOOL)animated{
    
    
    self.navigationController.navigationBar.hidden = NO;
    
    self.tabBarController.tabBar.hidden = NO;
    
    
    
}


- (void)viewDidLoad {
    
    
    [super viewDidLoad];
    
    [self createUI];
    
    // Do any additional setup after loading the view.
}
- (void)createUI{
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIView * titleview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_W, 128.0/1334*SCREEN_H)];
    
    titleview.backgroundColor = COLORRGBA(7, 24, 57, 1);
    
    [self.view addSubview:titleview];
    
    
    float fontsize = 18;
    
    float corensize = 17;
    
    fontsize = SCREEN_H < 667 ? 16 : 20 ;
    
    corensize = SCREEN_H < 667 ? 15 : 19 ;

    
    if (SCREEN_H == 667) {
        
        fontsize = 18;
        
        corensize = 17;
        
    }
    
    
    
    UIButton * leftlable  = [[UIButton alloc]initWithFrame:CGRectMake(0, 20+14.0/1334*SCREEN_H, 80.0/W_BASE*SCREEN_W, 60.0/1334.0*SCREEN_H)];
    
    [leftlable setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    
    leftlable.titleLabel.font = [UIFont fontWithName:@"iconfont" size:fontsize+3];
    
    [leftlable setTitle:@"\U0000e697" forState:UIControlStateNormal];
    
    
    
    [leftlable.titleLabel setTextAlignment:NSTextAlignmentCenter];
    
    [leftlable addTarget:self action:@selector(enterClick:) forControlEvents:UIControlEventTouchUpInside];
    
    [titleview addSubview:leftlable];
    
    UILabel * titlelab = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMinY(leftlable.frame), SCREEN_W, CGRectGetHeight(leftlable.frame))];
    
    titlelab.textAlignment = NSTextAlignmentCenter;
    
    titlelab.textColor = [UIColor whiteColor];
    
    titlelab.font = [UIFont systemFontOfSize:fontsize - 1];
    
    titlelab.text = @"我的客服";
    
    [titleview addSubview:titlelab];
    
    
    //icon图标
    
    UIButton * iconbtn = [[UIButton alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(titleview.frame)+330.0/H_BASE*SCREEN_H, 140.0/W_BASE*SCREEN_W, 140.0/H_BASE*SCREEN_H)];
    
    
    [self.view addSubview:iconbtn];
    
    iconbtn.center = CGPointMake(self.view.center.x, iconbtn.center.y);
    
    iconbtn.titleLabel.font = [UIFont fontWithName:@"iconfont" size:fontsize+45];
    
    [iconbtn setTitle:@"\U0000e604" forState:UIControlStateNormal];
    
    [iconbtn setTitleColor:COLORRGBA(38, 146, 255, 1) forState:UIControlStateNormal];
    
    iconbtn.titleLabel.textAlignment = NSTextAlignmentCenter;
    
    
    [iconbtn setTitleEdgeInsets:UIEdgeInsetsMake(20, 0, 0, 10)];

    
    //phonestring
    
    phonestring = @"022-60760091";
    
    phonelab = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(titleview.frame)+478.0/H_BASE*SCREEN_H, SCREEN_W, 90.0/H_BASE*SCREEN_H)];
    
    phonelab.textColor = COLORRGBA(153, 153, 153, 1);
    
    phonelab.font = [UIFont systemFontOfSize:fontsize - 4];
    
    [self.view addSubview:phonelab];
    
    phonelab.textAlignment = NSTextAlignmentCenter;
    
    phonelab.text = [NSString stringWithFormat:@"我的客服:  %@",phonestring];
    
    phonebtn = [[UIButton alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(phonelab.frame)+30.0/H_BASE*SCREEN_H, 250.0/W_BASE*SCREEN_W, 70.0/H_BASE*SCREEN_H)];
    
    phonebtn.backgroundColor = COLORRGBA(59, 214, 117, 1);
    
    phonebtn.center  = CGPointMake(self.view.center.x, phonebtn.center.y);
    
    [self.view addSubview:phonebtn];
    
    [phonebtn setTitle:@"拨打电话" forState:UIControlStateNormal];
    
    [phonebtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    phonebtn.titleLabel.font = [UIFont systemFontOfSize:fontsize - 3];
    
    phonebtn.layer.cornerRadius = corensize;
    
    phonebtn.clipsToBounds = YES;
    
    [phonebtn addTarget:self action:@selector(phoneNow:) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    
    
}

- (void)enterClick:(UIButton *)btn{
    
    
    [self.navigationController popViewControllerAnimated:YES];
    
    
    
}

- (void)phoneNow:(UIButton *)btn{

 //拨打电话

    
    NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",phonestring];
    UIWebView * callWebview = [[UIWebView alloc] init];
    [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
    [self.view addSubview:callWebview];
                            
                            

}
                            
                            
                            

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
